<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateKfPermissions extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('permissions', function (Blueprint $table) {
            $table->id();
            $table->string("name", 20)->default('')->comment("权限名称");
            $table->unsignedInteger("menuId")->default(0)->comment("菜单id");
            $table->string("action", 50)->default('')->comment("访问路径");
            $table->tinyInteger("status")->default(0)->comment("状态,0:正常,1:停用,2:其他");
            $table->string("additionMenuId", 50)->default('')->comment("附加菜单 id 做绑定");
            $table->tinyInteger('platform')->default(0)->comment("默认0 1(web)品牌端 2(web)门店端 3:pos ");
            $table->tinyInteger("accessId")->default(0)->comment("关联权限id");
            $table->tinyInteger('isDeleted')->default(0)->comment("是否删除 0：未删除，1：已删除");
            $table->integer("createdAt")->default(0)->comment("创建时间");
            $table->integer("updatedAt")->default(0)->comment("修改时间");
            $table->index("createdAt", "idx_created_at");

            $table->collation = 'utf8mb4_general_ci';
        });

        $prefix = config('other.DB_PREFIX', '');
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `{$prefix}permissions` COMMENT = '权限表'"); //表注释
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('permissions');
    }
}
